from flask_wtf import FlaskForm
from wtforms import StringField, TextAreaField, SubmitField, SelectMultipleField
from wtforms.validators import DataRequired, Length

class QuestionForm(FlaskForm):
    title = StringField('标题', validators=[
        DataRequired(message='标题不能为空'),
        Length(min=5, max=255, message='标题长度应在5-255个字符之间')
    ])
    content = TextAreaField('问题详情', validators=[
        DataRequired(message='问题详情不能为空'),
        Length(min=10, message='问题详情至少需要10个字符')
    ])
    tags = SelectMultipleField('标签', coerce=int)
    submit = SubmitField('提交问题')

class AnswerForm(FlaskForm):
    content = TextAreaField('回答', validators=[
        DataRequired(message='回答内容不能为空'),
        Length(min=5, message='回答内容至少需要5个字符')
    ])
    submit = SubmitField('提交回答')

class SearchForm(FlaskForm):
    query = StringField('搜索问题', validators=[DataRequired()])
    submit = SubmitField('搜索') 